package com.fyy.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author fyy
 * @Description
 * @Date 2020/7/23 14:50
 */
public class Meal {

    private List<FoodItem> foodItems = new ArrayList<FoodItem>();

    public void addItem(FoodItem item){
        foodItems.add(item);
    }

    public float getCost(){
        float cost = 0.0f;
        for (FoodItem item : foodItems) {
            cost += item.price();
        }
        return cost;
    }

    public void showItems(){
        for (FoodItem item : foodItems) {
            System.out.print("食品 : "+item.name());
            System.out.print(", 包装 : "+item.pack().pack());
            System.out.println(", 价格 : "+item.price());
        }
    }

}
